fix(types): add CreateMediaBuySubmittedResponse alias and fix handler return type#573
Closed
fix(types): add CreateMediaBuySubmittedResponse alias and fix handler return type#573
Conversation
… return type - Adds `CreateMediaBuySubmittedResponse = CreateMediaBuyResponse3` alias so implementors have a semantic name instead of the internal `Response3` suffix. - Exports the alias from `adcp.types` (`__init__.py` + `__all__`). - Fixes `PlatformHandler.create_media_buy` return annotation from `CreateMediaBuySuccessResponse` to `CreateMediaBuyResponse` (the full union) and updates the matching `cast()`. - Adds `status` (const "submitted") and `task_id` (required string) to `create-media-buy-async-response-submitted.json` so the SDK's strict validator produces a clear missing-field error instead of propagating to FastMCP's misleading enum error. Fixes #570 https://claude.ai/code/session_01MXKE7txstMT3B7aTctfXcZ
- Add is_create_media_buy_submitted() TypeGuard; fix is_create_media_buy_success() to return False for submitted envelopes (status=='submitted' check). - Expand guards.py CreateMediaBuyResponse local union to include the submitted branch. - Export is_create_media_buy_submitted from adcp.types and CreateMediaBuySubmittedResponse from the top-level adcp package alongside the success/error siblings. - Update CreateMediaBuySubmitted generated class to include required status and task_id fields, bringing the standalone schema's Python representation in sync with the updated create-media-buy-async-response-submitted.json. - Regenerate public API snapshot. https://claude.ai/code/session_01MXKE7txstMT3B7aTctfXcZ
Contributor
Author
Contributor
Author
|
Acknowledged — confirmed #575 (f7960ed) covers the handler return-type widening and Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #570
Summary
Three non-breaking SDK fixes for the async media-buy submitted branch, surfaced by the FastMCP validator misreport. Root cause (confirmed empirically): when a
status='submitted'response is missingtask_id, all threeanyOfbranches fail validation and jsonschema surfaces the deepest-path error — a misleading'submitted' is not one of [...]enum mismatch on Branch 0 — rather than the actualrequired: task_idfailure on Branch 2.Changes:
src/adcp/decisioning/handler.py— FixPlatformHandler.create_media_buyreturn annotation fromCreateMediaBuySuccessResponsetoCreateMediaBuyResponse(the three-branch union). The previous annotation was a static lie that misled mypy users and code reviewers.src/adcp/types/aliases.py/__init__.py/adcp/__init__.py— AddCreateMediaBuySubmittedResponse = CreateMediaBuyResponse3alias and export it from all three public surfaces so implementors have a semantic name instead of the internalResponse3suffix.schemas/cache/media-buy/create-media-buy-async-response-submitted.json— Addstatus(const"submitted") andtask_id(string, required) to the standalone submitted schema. Withresponse_mode="strict"the SDK's ownvalidate_response()will now catch a missingtask_idwith a clear message.src/adcp/types/guards.py— UpdateCreateMediaBuyResponselocal union alias to include the submitted branch; fixis_create_media_buy_success()to returnFalsefor submitted envelopes; addis_create_media_buy_submitted()TypeGuard.src/adcp/types/generated_poc/media_buy/create_media_buy_async_response_submitted.py— Bring the standalone generated class in sync with the updated schema (addstatus+task_idrequired fields).tests/fixtures/public_api_snapshot.json— Regenerated to include new exports.Nit (not fixed, noted for reviewers): Four sibling standalone async-submitted schemas (
update-media-buy,build-creative,get-products,sync-catalogs) remain underspecified in the same way. Canonical definitions in the bundled response schemas enforcerequired: [status, task_id]correctly; follow-up to bring standalone schemas to parity.What tested
ruff check— passes on all modified filesmypyon modified files — no new errors (pre-existing errors in unrelated files unchanged)pytest -k "media_buy or create_media or public_api"— 135 passed, 12 skippedPre-PR review
task_idis unambiguously required per AdCP async task contract (confirmed viacreate-media-buy-response.jsonBranch 2 andcomply-test-controller-request.json);additionalProperties: truecorrect and consistent with established pattern; change is non-breaking per specSession: https://claude.ai/code/session_01MXKE7txstMT3B7aTctfXcZ
Generated by Claude Code